package com.demo.apparel.mapper.uniapp;

import com.demo.apparel.entity.ClothesType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WxClothesTypeMapper {

    @Select("SELECT id, type_name AS typeName, keywords, sort, create_time AS createTime, category FROM clothes_type WHERE category = #{category} ORDER BY sort ASC")
    List<ClothesType> selectByCategory(Integer category);

    // 如果你需要查询全部也可以写一个
//    @Select("SELECT id, type_name AS typeName, keywords, sort, create_time AS createTime, category FROM clothes_type ORDER BY sort ASC")
//    List<ClothesType> selectAll();
    @Select("SELECT id, type_name AS typeName, keywords, sort, create_time AS createTime, category FROM clothes_type ORDER BY sort ASC")
    List<ClothesType> selectAll();


    @Select("""
    SELECT DISTINCT category
    FROM clothes_type
    WHERE FIND_IN_SET(#{keyword}, REPLACE(keywords, '，', ','))
""")
    List<String> findCategoriesByKeyword(@Param("keyword") String keyword);


}
